#This example shows how to formulate the wyndor glass co. problem
#The way that we model this problem can be altered to use modeling language
#But We still need to be clear about the model to be able to manipulate it

import cplex
from cplex.exceptions import CplexError
import sys
import numpy as np

c = cplex.Cplex()
#c.parameters.simplex.display.set(2)

#set objective sense
c.objective.set_sense(c.objective.sense.maximize)

#set variables
c.variables.add(names=["x1","x2"],
                lb =  [0,0],
                ub =  [cplex.infinity, cplex.infinity],
                obj = [3, 5])

rhss = np.random.uniform(size=3)

#set constraints
c.linear_constraints.add(lin_expr = [[[0],[1.0]],
                                     [[1],[2.0]],
                                     [[0,1],[3.0, 2.0]]],
                         senses = ["L","L","L"],
                         rhs = rhss,
                         names = ["c1","c2","c3"])
#rhs = [4.0, 12.0, 18.0],
#[cplex.SparsePair(ind=["x1"], val=[1.0]),
# cplex.SparsePair(ind=["x2"], val=[2.0]),
# cplex.SparsePair(ind=["x1","x2"], val=[3.0, 2.0])],

c.solve()

sol = c.solution
print 

# print out problem info
#print c.linear_constraints.get_rows()

# solution.get_status() returns an integer code
print "Solution status = " , sol.get_status(), ":",

# the following line prints the corresponding string
print sol.status[sol.get_status()]

# get solutions
print "Solutions: ", sol.get_values()

# get objective values
print "Objective values: " , sol.get_objective_value()

